package com.example.news;

import com.example.news.fraction.HomeFraction;
import com.example.news.pref.DisplayMode;
import com.example.news.slice.MainAbilitySlice;
import ohos.aafwk.ability.Ability;
import ohos.aafwk.ability.fraction.FractionAbility;
import ohos.aafwk.content.Intent;
import ohos.agp.animation.AnimatorProperty;
import ohos.agp.components.*;
import ohos.agp.utils.Color;
import ohos.agp.window.dialog.ToastDialog;
import ohos.agp.window.service.Window;
import ohos.agp.window.service.WindowManager;
import ohos.eventhandler.EventHandler;
import ohos.eventhandler.EventRunner;

public class MainAbility extends FractionAbility implements Component.ClickedListener {
    private Component mImgTitleMenu;
    private Component mImgTitleSet;

//    private TabList mTabList;
//    private PageSlider mPageSlider;

    private Component mDlSnackFlat;
    private Component mDlSnackLayout;
    private Text mTxtSnackLayoutText;

    private Component mCptPopupHolder;
    private Component mDlPopupRoot;
    private Component mDlPopupItem;
    private Component mDlPopupItemDay;
    private Component mDlPopupItemNight;
    private Image mImgPopupItemIconDay;
    private Image mImgPopupItemIconNight;

    private Component mCptDrawerHolder;
    private Component mDlDrawerLayout;
    private Image mImgDrawerCenterHomeIcon;
    private Text mTxtDrawerCenterHomeText;
    private Image mImgDrawerCenterMessageIcon;
    private Text mTxtDrawerCenterMessageText;
    private Image mImgDrawerCenterFriendIcon;
    private Text mTxtDrawerCenterFriendText;
    private Image mImgDrawerCenterDiscussionIcon;
    private Text mTxtDrawerCenterDiscussionText;
    private Image mImgDrawerBottomItem1Icon;
    private Text mTxtDrawerBottomItem1Text;
    private Image mImgDrawerBottomItem2Icon;
    private Text mTxtDrawerBottomItem2Text;
    private AnimatorProperty mDrawerAnimator;
    private boolean mDrawerFlag = false;
    private int mDrawerCenterFlag = -1;
    private boolean mDrawerBottomItem1Flag = false;
    private boolean mDrawerBottomItem2Flag = false;

    //    private List<ListContainer> mListPages;
    private final EventHandler handler = new EventHandler(EventRunner.getMainEventRunner());

    private com.example.news.view.RippleView home;
    private StackLayout mStackLayout;

    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_main);

        //取消状态栏
//        getWindow().addFlags(WindowManager.LayoutConfig.MARK_FULL_SCREEN);

        //设置状态栏颜色
        Window window=getWindow();
        window.setStatusBarColor(Color.rgb(89,104,227));
        window.setStatusBarVisibility(Component.VISIBLE);


        initViewPage();
        initViewListener();
        process();
        home = findComponentById(ResourceTable.Id_dl_main_drawer_center_home);
        home.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                loadFraction(0);
            }
        });
        loadFraction(0);

    }

    @Override
    protected void onBackground() {
        super.onBackground();
        if (mDrawerAnimator != null) {
            mDrawerAnimator = null;
        }
        handler.removeAllEvent();
    }

    @Override
    protected void onForeground(Intent intent) {
        super.onForeground(intent);
        if (mDlSnackLayout.getVisibility() == Component.VISIBLE) {
            mDlSnackLayout.setVisibility(Component.HIDE);
        }
    }
    private void loadFraction(int i) {
        switch (i) {
            case 0:
                getFractionManager()
                        .startFractionScheduler()
                        .replace(ResourceTable.Id_stacklayout, new HomeFraction())
                        .submit();
                break;
//            case 1:
//                getFractionManager()
//                        .startFractionScheduler()
//                        .replace(ResourceTable.Id_stacklayout, new VedioFraction())
//                        .submit();
//                break;
//            case 2:
//                getFractionManager()
//                        .startFractionScheduler()
//                        .replace(ResourceTable.Id_stacklayout, new MeFraction())
//                        .submit();
//                break;
            default:
                break;
        }
    }
    @Override
    public void onClick(Component cpt) {
        topClick(cpt);
        drawerClick(cpt);
        popupClick(cpt);
    }

    private void topClick(Component cpt) {
        switch (cpt.getId()) {
            case ResourceTable.Id_cpt_main_drawer_holder:
            case ResourceTable.Id_img_main_title_menu:
                drawerToggle();
                break;
            case ResourceTable.Id_img_main_title_set:
                showPopupRoot();
                break;
            case ResourceTable.Id_dl_main_snack_flat:
                if (mDlSnackLayout.getVisibility() == Component.HIDE) {
                    mDlSnackLayout.setVisibility(Component.VISIBLE);
                    handler.postTask(snackDismissListener, 2000);
                }
                break;
            default:
                break;
        }
    }

    private void drawerClick(Component cpt) {
        switch (cpt.getId()) {
            case ResourceTable.Id_dl_main_drawer_center_home:
                mDrawerCenterFlag = 1;
//                changeDrawerCenter();
                drawerToggle();
                break;
            case ResourceTable.Id_dl_main_drawer_center_msg:
                mDrawerCenterFlag = 2;
//                changeDrawerCenter();
                drawerToggle();
                break;
            case ResourceTable.Id_dl_main_drawer_center_friend:
                mDrawerCenterFlag = 3;
//                changeDrawerCenter();
                drawerToggle();
                break;
            case ResourceTable.Id_dl_main_drawer_center_discussion:
                mDrawerCenterFlag = 4;
//                changeDrawerCenter();
                drawerToggle();
                break;
            case ResourceTable.Id_dl_main_drawer_bottom_item1:
                mDrawerBottomItem1Flag = true;
//                changeDrawerBottom();
                drawerToggle();
                break;
            case ResourceTable.Id_dl_main_drawer_bottom_item2:
                mDrawerBottomItem2Flag = true;
//                changeDrawerBottom();
                drawerToggle();
                break;
            default:
                break;
        }
    }

    private void popupClick(Component cpt) {
        switch (cpt.getId()) {
            case ResourceTable.Id_cpt_common_popup_holder:
                disPopupRoot();
                disPopupItem();
                break;
            case ResourceTable.Id_dl_common_popup_root:
                showPopupItem();
                break;
            case ResourceTable.Id_dl_common_popup_item_day:
                disPopupItem();
                changeMode(DisplayMode.MODEL_DAY);
                break;
            case ResourceTable.Id_dl_common_popup_item_night:
                disPopupItem();
                changeMode(DisplayMode.MODEL_NIGHT);
                break;
            default:
                break;
        }
    }

    /**
     * 初始化页面组件View
     */
    private void initViewPage() {
        mImgTitleMenu = findComponentById(ResourceTable.Id_img_main_title_menu);
        mImgTitleSet = findComponentById(ResourceTable.Id_img_main_title_set);

//        Component tabList = findComponentById(ResourceTable.Id_tab_main_list);
//        if (tabList instanceof TabList) {
//            mTabList = (TabList) tabList;
//        }
//        Component pageSlider = findComponentById(ResourceTable.Id_page_main_slider);
//        if (pageSlider instanceof PageSlider) {
//            mPageSlider = (PageSlider) pageSlider;
//        }
        mDlSnackFlat = findComponentById(ResourceTable.Id_dl_main_snack_flat);
        mDlSnackLayout = findComponentById(ResourceTable.Id_dl_main_snack_layout);
        Component txtSnackLayoutText = findComponentById(ResourceTable.Id_txt_main_snack_layout_text);
        if (txtSnackLayoutText instanceof Text) {
            mTxtSnackLayoutText = (Text) txtSnackLayoutText;
        }
        mCptDrawerHolder = findComponentById(ResourceTable.Id_cpt_main_drawer_holder);
        mDlDrawerLayout = findComponentById(ResourceTable.Id_dl_main_draw);

        mCptPopupHolder = findComponentById(ResourceTable.Id_cpt_common_popup_holder);
        mDlPopupRoot = findComponentById(ResourceTable.Id_dl_common_popup_root);
        mDlPopupItem = findComponentById(ResourceTable.Id_dl_common_popup_item);
        mDlPopupItemDay = findComponentById(ResourceTable.Id_dl_common_popup_item_day);
        mDlPopupItemNight = findComponentById(ResourceTable.Id_dl_common_popup_item_night);
        Component imgPopupItemIconDay = findComponentById(ResourceTable.Id_img_common_popup_item_icon_day);
        if (imgPopupItemIconDay instanceof Image) {
            mImgPopupItemIconDay = (Image) imgPopupItemIconDay;
        }
        Component imgPopupItemIconNight = findComponentById(ResourceTable.Id_img_common_popup_item_icon_night);
        if (imgPopupItemIconNight instanceof Image) {
            mImgPopupItemIconNight = (Image) imgPopupItemIconNight;
        }
        Component imgDrawerCenterHomeIcon = findComponentById(ResourceTable.Id_img_main_drawer_center_home_icon);
        if (imgDrawerCenterHomeIcon instanceof Image) {
            mImgDrawerCenterHomeIcon = (Image) imgDrawerCenterHomeIcon;
        }
        Component txtDrawerCenterHomeText = findComponentById(ResourceTable.Id_txt_main_drawer_center_home_text);
        if (txtDrawerCenterHomeText instanceof Text) {
            mTxtDrawerCenterHomeText = (Text) txtDrawerCenterHomeText;
        }
        Component stackLayout = findComponentById(ResourceTable.Id_stacklayout);
        if (stackLayout instanceof StackLayout) {
            mStackLayout = (StackLayout) stackLayout;
        }
        initViewPage1();
    }

    private void initViewPage1() {
        Component imgDrawerCenterMessageIcon = findComponentById(ResourceTable.Id_img_main_drawer_center_msg_icon);
        if (imgDrawerCenterMessageIcon instanceof Image) {
            mImgDrawerCenterMessageIcon = (Image) imgDrawerCenterMessageIcon;
        }
        Component txtDrawerCenterMessageText = findComponentById(ResourceTable.Id_txt_main_drawer_center_msg_text);
        if (txtDrawerCenterMessageText instanceof Text) {
            mTxtDrawerCenterMessageText = (Text) txtDrawerCenterMessageText;
        }
        Component imgDrawerCenterFriendIcon = findComponentById(ResourceTable.Id_img_main_drawer_center_friend_icon);
        if (imgDrawerCenterFriendIcon instanceof Image) {
            mImgDrawerCenterFriendIcon = (Image) imgDrawerCenterFriendIcon;
        }
        Component txtDrawerCenterFriendText = findComponentById(ResourceTable.Id_txt_main_drawer_center_friend_text);
        if (txtDrawerCenterFriendText instanceof Text) {
            mTxtDrawerCenterFriendText = (Text) txtDrawerCenterFriendText;
        }
        Component imgDrawerCenterDiscussionIcon =
                findComponentById(ResourceTable.Id_img_main_drawer_center_discussion_icon);
        if (imgDrawerCenterDiscussionIcon instanceof Image) {
            mImgDrawerCenterDiscussionIcon = (Image) imgDrawerCenterDiscussionIcon;
        }
        Component txtDrawerCenterDiscussionText =
                findComponentById(ResourceTable.Id_txt_main_drawer_center_discussion_text);
        if (txtDrawerCenterDiscussionText instanceof Text) {
            mTxtDrawerCenterDiscussionText = (Text) txtDrawerCenterDiscussionText;
        }
        Component imgDrawerBottomItem1Icon = findComponentById(ResourceTable.Id_img_main_drawer_bottom_item1_icon);
        if (imgDrawerBottomItem1Icon instanceof Image) {
            mImgDrawerBottomItem1Icon = (Image) imgDrawerBottomItem1Icon;
        }
        Component txtDrawerBottomItem1Text = findComponentById(ResourceTable.Id_txt_main_drawer_bottom_item1_text);
        if (txtDrawerBottomItem1Text instanceof Text) {
            mTxtDrawerBottomItem1Text = (Text) txtDrawerBottomItem1Text;
        }
        Component imgDrawerBottomItem2Icon = findComponentById(ResourceTable.Id_img_main_drawer_bottom_item2_icon);
        if (imgDrawerBottomItem2Icon instanceof Image) {
            mImgDrawerBottomItem2Icon = (Image) imgDrawerBottomItem2Icon;
        }
        Component txtDrawerBottomItem2Text = findComponentById(ResourceTable.Id_txt_main_drawer_bottom_item2_text);
        if (txtDrawerBottomItem2Text instanceof Text) {
            mTxtDrawerBottomItem2Text = (Text) txtDrawerBottomItem2Text;
        }
    }

    /**
     * 初始化页面监听器Listener
     */
    private void initViewListener() {
//        mTabList.addTabSelectedListener(tabSelectedListener);
//        mPageSlider.addPageChangedListener(pageChangedListener);

        mImgTitleMenu.setClickedListener(this);
        mImgTitleSet.setClickedListener(this);

        mDlSnackFlat.setClickedListener(this);

        mCptPopupHolder.setClickedListener(this);
        mDlPopupRoot.setClickedListener(this);
        mDlPopupItemDay.setClickedListener(this);
        mDlPopupItemNight.setClickedListener(this);

        mCptDrawerHolder.setClickedListener(this);
        findComponentById(ResourceTable.Id_dl_main_drawer_top).setClickedListener(this);
        findComponentById(ResourceTable.Id_dl_main_drawer_center).setClickedListener(this);
        findComponentById(ResourceTable.Id_dl_main_drawer_bottom).setClickedListener(this);
        findComponentById(ResourceTable.Id_dl_main_drawer_center_home).setClickedListener(this);
        findComponentById(ResourceTable.Id_dl_main_drawer_center_msg).setClickedListener(this);
        findComponentById(ResourceTable.Id_dl_main_drawer_center_friend).setClickedListener(this);
        findComponentById(ResourceTable.Id_dl_main_drawer_center_discussion).setClickedListener(this);
        findComponentById(ResourceTable.Id_dl_main_drawer_bottom_item1).setClickedListener(this);
        findComponentById(ResourceTable.Id_dl_main_drawer_bottom_item2).setClickedListener(this);
    }

    /**
     * 业务处理
     */
    private void process() {
//        initStatusBar();
//        initPageData();
////        initSnackFlat();
//        applyDisplayMode();
    }

    /**
     * 初始化状态栏显示
     */
    private void initStatusBar() {
//        changeBgOfStatusBar();
    }

    /**
     * 初始化页面数据
     */
//    private void initPageData() {
////        List<Component> pages = new ArrayList<>();
////        mListPages = new ArrayList<>();
//        for (int i = 1; i < 4; i++) {
////            pages.add(createPage());
//            TabList.Tab tab = mTabList.new Tab(null);
//            tab.setText(String.format(Locale.ROOT, "首页 %s", i));
//            mTabList.addTab(tab);
//        }
//        mTabList.selectTabAt(0);
////        mPageSlider.setProvider(new PageProvider(pages));
//    }

//    /**
//     * 初始化SnackFlat圆形显示
//     */
//    private void initSnackFlat() {
//        Cheeses.initFloatAction(this, mDlSnackFlat);
//    }

    /**
     * PageSlider的页面创建
     *
     * @return 页面组件
     */
//    private Component createPage() {
//        final Component rootView = LayoutScatter.getInstance(this)
//                .parse(ResourceTable.Layout_layout_main_provider_page_item, null, false);
//        Component temp = rootView.findComponentById(ResourceTable.Id_list_container);
//        if (temp instanceof ListContainer) {
//            ListContainer container = (ListContainer) temp;
//            new Thread(new Runnable() {
//                @Override
//                public void run() {
//                    ZZRHttp.get("http://v.juhe.cn/toutiao/index?type=youxi&page=&page_size=5&is_filter=&key=2d771c5dadfce4d4800ff96349664327", new ZZRCallBack.CallBackString() {
//                        @Override
//                        public void onFailure(int i, String s) {
//                            System.out.println("请求失败");
//                        }
//
//                        @Override
//                        public void onResponse(String s) {
//                            System.out.println(s);
//                            Gson gson = new Gson();
//                            NewsBean news = gson.fromJson(s, NewsBean.class);
//                            container.setItemProvider(new NewsProvider(news.getResult().getData(), MainAbility.this));
//                        }
//                    });
//                    getMainTaskDispatcher().asyncDispatch(new Runnable() {
//                        @Override
//                        public void run() {
//                            mListPages.add(container);
//                        }
//                    });
//                }
//            }).start();
//
//
//        }
//        return rootView;
//    }


    /**
     * Tab选择监听器Listener
     */
    private final TabList.TabSelectedListener tabSelectedListener = new TabList.TabSelectedListener() {
        @Override
        public void onSelected(TabList.Tab tab) {
//            mPageSlider.setCurrentPage(tab.getPosition(), true);
        }

        @Override
        public void onUnselected(TabList.Tab tab) {
        }

        @Override
        public void onReselected(TabList.Tab tab) {
        }
    };

    /**
     * PageSlider改变监听器Listener
     */
    private final PageSlider.PageChangedListener pageChangedListener = new PageSlider.PageChangedListener() {
        @Override
        public void onPageSliding(int i, float v, int i1) {
        }

        @Override
        public void onPageSlideStateChanged(int i) {
        }

        @Override
        public void onPageChosen(int i) {
//            mTabList.selectTabAt(i);
        }
    };

    /**
     * Snack Dismiss监听器
     */
    private final Runnable snackDismissListener = new Runnable() {
        @Override
        public void run() {
            if (mDlSnackLayout.getVisibility() == Component.VISIBLE) {
                mDlSnackLayout.setVisibility(Component.HIDE);
            }
        }
    };

    /**
     * SliderDrawer开关
     */
    private void drawerToggle() {
        if (mDrawerAnimator == null) {
            mDrawerAnimator = mDlDrawerLayout.createAnimatorProperty();
        }
        float start = mDrawerFlag ? 0 : -700;
        float stop = mDrawerFlag ? -700 : 0;
        mDrawerAnimator.moveFromX(start).moveToX(stop).setDuration(300);
        mDrawerAnimator.start();
        mDrawerFlag = !mDrawerFlag;
        mCptDrawerHolder.setVisibility(mDrawerFlag ? Component.VISIBLE : Component.HIDE);
    }

    /**
     * 切换显示模式
     *
     * @param value value
     */
    private void changeMode(int value) {
        int mode = DisplayMode.getDisplayMode();
        if (!DisplayMode.hasDisplayMode() || mode != value) {
            DisplayMode.setDisplayMode(value);
            applyDisplayMode();
        }
    }

    /**
     * 应用显示模式
     */
    private void applyDisplayMode() {
//        changeBgOfStatusBar();
//        changeBgOfTabBar();
//        changeBgOfListPage();
//        changeBgOfPopup();
//        changeBgOfDrawer();
//        changeBgOfSnack();
    }

    /**
     * 切换状态栏背景
     */
//    private void changeBgOfStatusBar() {
//        boolean night = DisplayMode.isNight();
//        getWindow().setStatusBarColor(Cheeses.getColorFromRes(this, night ?
//                ResourceTable.Color_statusBgNight :
//                ResourceTable.Color_statusBgDay).getValue());
//    }

    /**
     * 切换TabList背景
     */
//    private void changeBgOfTabBar() {
//        boolean night = DisplayMode.isNight();
//        Cheeses.setBgColor(this, mTabList, night ?
//                ResourceTable.Color_tabNorBgNight :
//                ResourceTable.Color_white);
//        int normal = Cheeses.getColorVersion4(this, night ?
//                ResourceTable.Color_tabNorTextNight :
//                ResourceTable.Color_tabNorTextDay);
//        int select = Cheeses.getColorVersion4(this, ResourceTable.Color_colorPrimary);
//        mTabList.setTabTextColors(normal, select);
//    }

    /**
     * 切换ListContainer背景
     */
//    private void changeBgOfListPage() {
//        for (ListContainer lc : mListPages) {
//            lc.getItemProvider().notifyDataChanged();
//        }
//    }

    /**
     * 切换Popup背景
     */
//    private void changeBgOfPopup() {
//        if (DisplayMode.hasDisplayMode()) {
//            boolean night = DisplayMode.isNight();
//            Cheeses.setBgColor(this, mDlPopupRoot, night ?
//                    ResourceTable.Color_popupBgNight :
//                    ResourceTable.Color_white);
//            Cheeses.setBgColor(this, mDlPopupItem, night ?
//                    ResourceTable.Color_popupBgNight :
//                    ResourceTable.Color_white);
//            mImgPopupItemIconDay.setImageElement(Cheeses.getGraphicElement(this, night ?
//                    ResourceTable.Graphic_ic_popup_item_no :
//                    ResourceTable.Graphic_ic_popup_item_yes));
//            mImgPopupItemIconNight.setImageElement(Cheeses.getGraphicElement(this, night ?
//                    ResourceTable.Graphic_ic_popup_item_yes :
//                    ResourceTable.Graphic_ic_popup_item_no));
//        }
//    }

    /**
     * 切换Drawer背景
     */
//    private void changeBgOfDrawer() {
//        boolean night = DisplayMode.isNight();
//        Cheeses.setBgColor(this, mDlDrawerLayout, night ?
//                ResourceTable.Color_drawerBgNight :
//                ResourceTable.Color_white);
//        changeDrawerCenter();
//        changeDrawerBottom();
//    }

    /**
     * 切换Snack背景
     */
//    private void changeBgOfSnack() {
//        boolean night = DisplayMode.isNight();
//        mDlSnackLayout.setBackground(Cheeses.getGraphicElement(this, night ?
//                ResourceTable.Graphic_bg_snack_night :
//                ResourceTable.Graphic_bg_snack_day));
//        mTxtSnackLayoutText.setTextColor(new Color(Cheeses.getColorVersion4(this, night ?
//                ResourceTable.Color_black :
//                ResourceTable.Color_white)));
//    }

    /**
     * ChangeDrawerCenter
     */
//    private void changeDrawerCenter() {
//        boolean night = DisplayMode.isNight();
//        changeDrawerCenterIcon(night);
//        changeDrawerCenterText(night);
//    }

//    private void changeDrawerCenterIcon(boolean night) {
//        int t1 = night ? ResourceTable.Graphic_ic_dashboard_night : ResourceTable.Graphic_ic_dashboard_day;
//        mImgDrawerCenterHomeIcon.setImageElement(
//                Cheeses.getGraphicElement(this, mDrawerCenterFlag == 1 ?
//                        ResourceTable.Graphic_ic_dashboard_check : t1));
//        int t2 = night ? ResourceTable.Graphic_ic_event_night : ResourceTable.Graphic_ic_event_day;
//        mImgDrawerCenterMessageIcon.setImageElement(
//                Cheeses.getGraphicElement(this, mDrawerCenterFlag == 2 ?
//                        ResourceTable.Graphic_ic_event_check : t2));
//        int t3 = night ? ResourceTable.Graphic_ic_headset_night : ResourceTable.Graphic_ic_headset_day;
//        mImgDrawerCenterFriendIcon.setImageElement(
//                Cheeses.getGraphicElement(this, mDrawerCenterFlag == 3 ?
//                        ResourceTable.Graphic_ic_headset_check : t3));
//        int t4 = night ? ResourceTable.Graphic_ic_forum_night : ResourceTable.Graphic_ic_forum_day;
//        mImgDrawerCenterDiscussionIcon.setImageElement(
//                Cheeses.getGraphicElement(this, mDrawerCenterFlag == 4 ?
//                        ResourceTable.Graphic_ic_forum_check : t4));
//    }

//    private void changeDrawerCenterText(boolean night) {
//        int norColor = night ? ResourceTable.Color_white : ResourceTable.Color_black;
//        mTxtDrawerCenterHomeText.setTextColor(
//                Cheeses.getColorFromRes(this, mDrawerCenterFlag == 1 ?
//                        ResourceTable.Color_drawerItemChecked : norColor));
//        mTxtDrawerCenterMessageText.setTextColor(
//                Cheeses.getColorFromRes(this, mDrawerCenterFlag == 2 ?
//                        ResourceTable.Color_drawerItemChecked : norColor));
//        mTxtDrawerCenterFriendText.setTextColor(
//                Cheeses.getColorFromRes(this, mDrawerCenterFlag == 3 ?
//                        ResourceTable.Color_drawerItemChecked : norColor));
//        mTxtDrawerCenterDiscussionText.setTextColor(
//                Cheeses.getColorFromRes(this, mDrawerCenterFlag == 4 ?
//                        ResourceTable.Color_drawerItemChecked : norColor));
//    }

    /**
     * ChangeDrawerBottom
     */
//    private void changeDrawerBottom() {
//        boolean night = DisplayMode.isNight();
//        int norColor = night ? ResourceTable.Color_white : ResourceTable.Color_black;
//        int t1 = night ? ResourceTable.Graphic_ic_dashboard_night : ResourceTable.Graphic_ic_dashboard_day;
//        mImgDrawerBottomItem1Icon.setImageElement(
//                Cheeses.getGraphicElement(this, mDrawerBottomItem1Flag ?
//                        ResourceTable.Graphic_ic_dashboard_check : t1));
//        mTxtDrawerBottomItem1Text.setTextColor(
//                Cheeses.getColorFromRes(this, mDrawerBottomItem1Flag ?
//                        ResourceTable.Color_drawerItemChecked : norColor));
//        int t2 = night ? ResourceTable.Graphic_ic_forum_night : ResourceTable.Graphic_ic_forum_day;
//        mImgDrawerBottomItem2Icon.setImageElement(
//                Cheeses.getGraphicElement(this, mDrawerBottomItem2Flag ?
//                        ResourceTable.Graphic_ic_forum_check : t2));
//        mTxtDrawerBottomItem2Text.setTextColor(
//                Cheeses.getColorFromRes(this, mDrawerBottomItem2Flag ?
//                        ResourceTable.Color_drawerItemChecked : norColor));
//    }

    /**
     * 显示PopupRoot
     */
    private void showPopupRoot() {
        if (mDlPopupRoot.getVisibility() != Component.VISIBLE) {
            mDlPopupRoot.setVisibility(Component.VISIBLE);
        }
        showPopupHolder();
    }

    /**
     * 关闭PopupRoot
     */
    private void disPopupRoot() {
        if (mDlPopupRoot.getVisibility() != Component.HIDE) {
            mDlPopupRoot.setVisibility(Component.HIDE);
        }
        disPopupHolder();
    }

    /**
     * 显示PopupItem
     */
    private void showPopupItem() {
        if (mDlPopupItem.getVisibility() != Component.VISIBLE) {
            mDlPopupItem.setVisibility(Component.VISIBLE);
        }
        disPopupRoot();
        showPopupHolder();
    }

    /**
     * 关闭PopupItem
     */
    private void disPopupItem() {
        if (mDlPopupItem.getVisibility() != Component.HIDE) {
            mDlPopupItem.setVisibility(Component.HIDE);
        }
        disPopupHolder();
    }

    /**
     * 显示PopupHolder
     */
    private void showPopupHolder() {
        if (mCptPopupHolder.getVisibility() != Component.VISIBLE) {
            mCptPopupHolder.setVisibility(Component.VISIBLE);
        }
    }

    /**
     * 关闭PopupHolder
     */
    private void disPopupHolder() {
        if (mCptPopupHolder.getVisibility() != Component.HIDE) {
            mCptPopupHolder.setVisibility(Component.HIDE);
        }
    }
}
